*===================================================================*
* White Identity in Canada
* Feodor Snagovsky
* University of Alberta
* November 8, 2024
*===================================================================*

* Frontmatter
clear all
set more off
capture log close
set scheme plotplainblind

* Set the working directory
cd "YOUR PATH HERE/Replication/"

* Load data
use "2024_Conspiracy_White_Identity_Raw.dta"

* ----------------------------------------------------------- * 
* Recoding and creating variables
* ----------------------------------------------------------- * 

* Recode "Don't Know" to missing
recode ethid_importance ethid_others (6=.)

* Reverse direction to make higher numbers correspond to stronger identity
revrs ethid_importance ethid_others Q102_4 Q102_5

* White identity scale
* For some reason, the "ethic_battery_" questions have been re-ordered through Qualtrics; variable names have slightly changed from pre-registration names 
alpha revethid_importance revethid_others ethid_battery_2 ethid_battery_4 ethid_battery_5 ethid_battery_6 ethid_battery_7 ethid_battery_8, item gen(white_con) std
* alpha = 0.90

* Age squared variable
gen age2 = age*age

* Quebec dummy variable
gen quebec = 0
replace quebec = 1 if province == 11
la var quebec "Quebec"

* Simplified gender variable
gen gender_s = .
replace gender_s = 1 if genderid == 1
replace gender_s = 2 if genderid == 2
replace gender_s = 3 if genderid >= 3 & genderid <= 6
la def gender_s 1 "Woman" 2 "Man" 3 "Another gender"
la val gender_s gender_s

gen woman = .
replace woman = 1 if gender_s == 1
replace woman = 0 if gender_s != 1 & gender_s != .
la def woman 0 "Not woman" 1 "Woman"
la val woman woman
la var woman "Woman"

* Simplified education variable
gen education_s = . 
replace education_s = 1 if education >= 1 & education <= 5
replace education_s = 2 if education == 6 | education == 8
replace education_s = 3 if education == 7
replace education_s = 4 if education >= 9 & education <= 11
la def education_s 1 "High School or Less" 2 "Some College or University" ///
	3 "Trade or Certificate" 4 "University"
la val education_s education_s

gen university = .
replace university = 0 if education_s >= 1 & education_s <= 3
replace university = 1 if education_s == 4
la def university 0 "No university" 1 "University"
la var university "University education" 

* Political interest
rename Q33_3 interest_federal

* Political knowledge
decode cps21_premier_name, gen(cps21_premier_name_str)
gen premier_name_coded = ""
replace premier_name_coded = "Danielle Smith" if province == 1
replace premier_name_coded = "David Eby" if province == 2
replace premier_name_coded = "Heather Stefanson" if province == 3
replace premier_name_coded = "Blaine Higgs" if province == 4
replace premier_name_coded = "Andrew Furey" if province == 5
replace premier_name_coded = "Caroline Cochrane" if province == 6
replace premier_name_coded = "Tim Houston" if province == 7
replace premier_name_coded = "P.J. Akeeagok" if province == 8
replace premier_name_coded = "Doug Ford" if province == 9
replace premier_name_coded = "Dennis King" if province == 10
replace premier_name_coded = "François Legault" if province == 11
replace premier_name_coded = "Scott Moe" if province == 12
replace premier_name_coded = "Ranj Pillai" if province == 13

gen knowledge1 = 0
gen knowledge2 = 0
gen knowledge3 = 0
replace knowledge1 = 1 if cps21_premier_name_str == premier_name_coded
replace knowledge2 = 1 if cps21_finmin_name == 1
replace knowledge3 = 1 if cps21_govgen_name == 3

gen political_knowledge = knowledge1 + knowledge2 + knowledge3

* Left-right ideology
rename Q31_1 left_right

* Satisfaction with democracy
revrs Q18
rename revQ18 satisfaction_democracy

* Label treatment groups
destring Condition, gen(treatment_group)
la def treatment_group 1 "White pop decreasing" 2 "VM pop increasing" ///
	3 "Immigrant pop increasing" 4 "Control"
la val treatment_group treatment_group
la var treatment_group "Treatment (Full)"

gen treatment_binary = .
replace treatment_binary = 0 if treatment_group == 4
replace treatment_binary = 1 if treatment_group >= 1 & treatment_group <= 3
la def treatment_binary 0 "Control" 1 "Treatment"
la val treatment_binary treatment_binary
la var treatment_binary "Treatment (Binary)"

* Gen dummy variable for ethnicity
gen ethnicity_s = .
replace ethnicity_s = 1 if ethnicity_macro_q == 5
replace ethnicity_s = 2 if ethnicity_macro_q != 5 & ethnicity_macro_q != .
la def ethnicity_s 1 "White" 2 "Indigenous or person of colour"
la val ethnicity_s ethnicity_s 

* Urban/rural
rename Q119 urban_rural

* Conspiracy Thinking
recode Q109_* (6=.)
alpha Q109_1 Q109_2 Q109_3 Q109_4 , item gen(consp_think) std /* alpha = 0.89 */

* Denialism: Q109_5 Q109_6 Q109_7 Q109_8

* Conspiracy endorsement 
foreach v of varlist conspiracy_lableak-conspiracy_activists {
	
	gen `v'_ord = .
	replace `v'_ord = 1 if `v' == 2
	replace `v'_ord = 2 if `v' == 3
	replace `v'_ord = 3 if `v' == 1
	la def `v'_ord 1 "non-conspiracy"  2 "equally likely"  3 "conspiracy"
	la val `v'_ord `v'_ord 
	
}

* Note that white replacement is not present in this list
alpha conspiracy_lableak_ord conspiracy_clhoax_ord conspiracy_wef_ord conspiracy_vaxdanger_ord conspiracy_deepstate_ord  conspiracy_microchip_ord conspiracy_china_ord conspiracy_15min_ord conspiracy_activists_ord, item gen(consp_endorse) std /* alpha = 0.85 */

* Racial resentment
alpha Q111_1 Q111_3 Q111_4 Q111_2, item std reverse(Q111_3 Q111_4) gen(racial_resentment) /* alpha = 0.71 */

* Outgroup thermometer (Jews, Muslims, ethnic minorities, aboriginal people)
alpha group_influence_6 group_influence_9 group_influence_11 group_influence_12, item std gen(outgroup_thermometer)  /* alpha = 0.9 */

* White thermometer
rename group_influence_8 white_thermometer

* White privilege
rename Q104_8 white_priv

* Perceptions of victimhood
alpha victimhood_1 victimhood_2 victimhood_3 victimhood_4, item std reverse (victimhood_1) gen(victimhood_index)  /* alpha = 0.73 */

* Party ID
rename Q16 partyid

* Final labels
la var age "Age"
la var age2 "Age (Squared)"
la var income "Income"
la var interest_federal "Political interest"
la var political_knowledge "Political knowledge"
la var left_right "Ideology (Right)"
la var satisfaction_democracy "Satisf. with democracy"
la var consp_think "Conspiracy Thinking"
la var consp_endorse "Conspiracy Endorsement"
la var conspiracy_white_rep_ord "White Replacement"
la var white_con "White Consciousness"
la var racial_resentment "Racial resentment"
la var outgroup_thermometer "Outgroup thermometer"
la var white_priv "White privilege"
la var victimhood_index "Victimhood"
la var white_thermometer "White thermometer"

save "2024_Conspiracy_White_Identity.dta", replace


* ----------------------------------------------------------- * 
* Models
* ----------------------------------------------------------- * 

keep if ethnicity_s == 1

global controlvars age age2 woman university income interest_federal political_knowledge left_right satisfaction_democracy quebec

* Bivariate 
eststo wrep_biv: ologit conspiracy_white_rep_ord white_con, or
eststo think_biv: regress consp_think white_con
eststo endorse_biv: regress consp_endorse c.white_con##c.consp_think

* Multivariate
eststo wrep_multi: ologit conspiracy_white_rep_ord white_con consp_think $controlvars, or
eststo think_multi: regress consp_think white_con $controlvars
eststo endorse_multi: regress consp_endorse c.white_con##c.consp_think $controlvars


********** Robustness Checks: Did another experiment earlier in the survey affect the results? No. **********

* Control group only 
eststo wrep_cgroup_biv: ologit conspiracy_white_rep_ord white_con if treatment_binary == 0, or
eststo think_cgroup_biv: regress consp_think white_con if treatment_binary == 0
eststo endorse_cgroup_biv: regress consp_endorse c.white_con##c.consp_think if treatment_binary == 0

eststo wrep_cgroup_multi: ologit conspiracy_white_rep_ord white_con consp_think $controlvars if treatment_binary == 0, or
eststo think_cgroup_multi: regress consp_think white_con $controlvars if treatment_binary == 0
eststo endorse_cgroup_multi: regress consp_endorse c.white_con##c.consp_think $controlvars if treatment_binary == 0
eststo endorse_cgroup_marg: margins, dydx(consp_think) at(white_con = (-1.75(0.25)1.5)) vsquish post
	

********** Robustness Checks: Omitted Variables **********

global robustnessvars racial_resentment outgroup_thermometer white_priv victimhood_index white_thermometer 

eststo wrep_robust: ologit conspiracy_white_rep_ord white_con consp_think $controlvars $robustnessvars, or
eststo think_robust: regress consp_think white_con $controlvars $robustnessvars
eststo endorse_robust: regress consp_endorse c.white_con##c.consp_think $controlvars $robustnessvars

********** Robustness Checks: Weighted Analyses **********

* Multivariate
eststo wrep_multi_wt: ologit conspiracy_white_rep_ord white_con consp_think $controlvars [aw=weight_general], or
eststo think_multi_wt: regress consp_think white_con $controlvars [aw=weight_general]	
eststo endorse_multi_wt: regress consp_endorse c.white_con##c.consp_think $controlvars [aw=weight_general]	
		
		
********** Robustness Checks: Partisanship **********


* Multivariate
eststo wrep_party: ologit conspiracy_white_rep_ord white_con consp_think age age2 woman university income interest_federal political_knowledge i.partyid satisfaction_democracy quebec $robustnessvars, or

eststo think_party: regress consp_think white_con age age2 woman university income interest_federal political_knowledge i.partyid satisfaction_democracy quebec $robustnessvars

eststo endorse_party: regress consp_endorse c.white_con##c.consp_think age age2 woman university income interest_federal political_knowledge i.partyid satisfaction_democracy quebec $robustnessvars
	

********** Robustness Checks: Ideologically Neutral and Left-wing CTs **********

alpha conspiracy_lableak_ord conspiracy_wef_ord conspiracy_vaxdanger_ord conspiracy_microchip_ord conspiracy_activists_ord, item gen(consp_endorse_nl) std /* alpha = 0.76 */
la var consp_endorse_nl "Conspiracy Endorsement"

eststo endorse_left: regress consp_endorse_nl c.white_con##c.consp_think age age2 woman university income interest_federal political_knowledge i.partyid left_right satisfaction_democracy quebec $robustnessvars
	
	
********** Robustness Checks: Compare to Census **********

* Table A1
egen agecat = cut(age), at(17,25,35,45,55,65,100)

tab province
tab agecat
tab gender_s
	
	
* ----------------------------------------------------------- * 
* Graphing
* ----------------------------------------------------------- * 
	
***** White Replacement *****

coefplot wrep_multi, name(wrep_multi, replace) eform xline(1, lwidth(thin) lpattern(dash)) drop(_cons) ///
	levels(95) msize(vsmall) xlabel(0(1)3) xscale(range(0(1)3)) title("White Replacement Conspiracy Beliefs")
graph export "figure1.jpg", replace
	
***** Conspiracy Thinking *****

coefplot think_multi, name(think_multi, replace) xline(0, lwidth(thin) lpattern(dash)) drop(_cons) ///
	levels(95) msize(vsmall) xlabel(-0.4(0.2)0.4) xscale(range(-0.4(0.2)0.4)) title("Conspiracy Thinking")
graph export "figure2.jpg", replace

***** Conspiracy Endorsement: WI x Thinking *****

coefplot endorse_multi, name(endorse_multi, replace) xline(0, lwidth(thin) lpattern(dash)) drop(_cons) ///
	levels(95) msize(vsmall) xlabel(-0.4(0.2)0.4) xscale(range(-0.4(0.2)0.4))  coeflabels(, interaction(" x ")) ///
	title("Non-Racial Conspiracy Endorsement")
graph export "figure3.jpg", replace 

quietly: regress consp_endorse c.white_con##c.consp_think $controlvars
eststo wi_marg: margins, dydx(consp_think) at(white_con = (-1.75(0.25)1.5)) vsquish post
marginsplot, recast(line) ciopt(color(black%20)) recastci(rarea) name(consp_think_x_wi, replace) ///
	title("Effects of White Consciousness on Conspiracy Endorsement at Levels of Conspiracy Thinking") 
graph export "figure4.jpg", replace
 

* ----------------------------------------------------------- * 
* Tables
* ----------------------------------------------------------- * 

global table_opts se replace label nogaps b(3) se(3) ///
	coeflabels(satisfaction_democracy "Satisfaction with Democracy")  ///	
	noomitted 
	
* Main effects
esttab wrep_biv wrep_multi using "table_a3.rtf", $table_opts eform
esttab think_biv think_multi using "table_a4.rtf", $table_opts
esttab endorse_biv endorse_multi using "table_a5.rtf", $table_opts
esttab wi_marg using "table_a6.rtf", margin replace nogaps b(3) se(3) label ///
	coeflabels(1._at "WI = -1.75" 2._at "WI = -1.5" ///
				3._at "WI = -1.25" 4._at "WI = -1.0" ///
				5._at "WI = -0.75" 6._at "WI = -0.5" ///
				7._at "WI = -0.25" 8._at "WI = 0" ///
				9._at "WI = 0.25" 10._at "WI = 0.5" ///
				11._at "WI = 0.75" 12._at "WI = 1.0" ///
				13._at "WI = 1.25" 14._at "WI = 1.5")
		
* Robustness Checks: Control Group Only
esttab wrep_cgroup_biv wrep_cgroup_multi using "table_a7.rtf", $table_opts eform
esttab think_cgroup_biv think_cgroup_multi using "table_a8.rtf", $table_opts
esttab endorse_cgroup_biv endorse_cgroup_multi using "table_a9.rtf", $table_opts
esttab endorse_cgroup_marg using "table_a10.rtf", margin replace nogaps b(3) se(3) label ///
	coeflabels(1._at "WI = -1.75" 2._at "WI = -1.5" ///
				3._at "WI = -1.25" 4._at "WI = -1.0" ///
				5._at "WI = -0.75" 6._at "WI = -0.5" ///
				7._at "WI = -0.25" 8._at "WI = 0" ///
				9._at "WI = 0.25" 10._at "WI = 0.5" ///
				11._at "WI = 0.75" 12._at "WI = 1.0" ///
				13._at "WI = 1.25" 14._at "WI = 1.5")

* Summary statistics
asdoc sum consp_think consp_endorse conspiracy_white_rep_ord white_con age age2 woman university income interest_federal political_knowledge left_right satisfaction_democracy quebec, label save(table_a2.doc) title(Descriptive statistics) replace

* Robustness Checks: Omitted Variables
esttab think_robust using "table_a11.rtf", $table_opts
esttab wrep_robust using "table_a12.rtf", $table_opts eform
esttab endorse_robust using "table_a13.rtf", $table_opts
		
* Robustness Checks: Weighting
esttab think_multi_wt using "table_a14.rtf", $table_opts
esttab wrep_multi_wt using "table_a15.rtf", $table_opts eform
esttab endorse_multi_wt using "table_a16.rtf", $table_opts
		
* Robustness Checks: Party ID
esttab think_party using "table_a20.rtf", $table_opts
esttab wrep_party using "table_a21.rtf", $table_opts eform
esttab endorse_party using "table_a22.rtf", $table_opts
		
* Robustness Checks: More ideologically neutral CTs
esttab endorse_left using "table_a24.rtf", $table_opts
		
				
**** Robustness Checks: Factor Analysis ****
global factorvars revethid_importance revethid_others ethid_battery_2 ethid_battery_4 ethid_battery_5 ethid_battery_6 ethid_battery_7 ethid_battery_8

factor $factorvars

* Determinant of correlation matrix, Bartlett's test, KMO
factortest $factorvars

* How many factors?
* net install fapara, from ("https://stats.oarc.ucla.edu/stat/stata/ado/analysis")
* ssc install minap

screeplot
fapara, pca reps(500)
minap $factorvars

* The results of this are Table A23 (Appendix J)
factor $factorvars, factor(1)
rotate, promax(1)
rotate, clear		
		
		
		
********** Robustness Checks: Ethnic Minority Respondents **********

use "2024_Conspiracy_White_Identity.dta", clear
		
rename white_con ethnic_consc
la var ethnic_consc "Ethnic consciousness"

global controlvars age age2 woman university income interest_federal political_knowledge left_right satisfaction_democracy quebec

global table_opts se replace label nogaps b(3) se(3) ///
	coeflabels(satisfaction_democracy "Satisfaction with Democracy")  ///	
	noomitted 
	
* Multivariate
eststo wrep_ethmin: ologit conspiracy_white_rep_ord ethnic_consc consp_think $controlvars if ethnicity_s == 2, or
eststo think_ethmin: regress consp_think ethnic_consc $controlvars if ethnicity_s == 2
eststo endorse_ethmin: regress consp_endorse c.ethnic_consc##c.consp_think $controlvars if ethnicity_s == 2

* Tables
esttab think_ethmin using "table_a17.rtf", $table_opts
esttab wrep_ethmin using "table_a18.rtf", $table_opts eform
esttab endorse_ethmin using "table_a19.rtf", $table_opts
	
* Compare to white respondents	
eststo think_white: regress consp_think ethnic_consc $controlvars if ethnicity_s == 1
suest think_ethmin think_white

test [think_ethmin_mean]ethnic_consc=[think_white_mean]ethnic_consc

		
* ---------------------------------------------- * 
* END OF FILE
* ---------------------------------------------- * 
